/**
 * @BusiServerEndpoint.java  COPYRIGHT xiaojian
 * 
 * Created on 2017年7月23日 下午4:46:15
 */
package xj.toolkit.access.busi;

import com.google.common.base.Preconditions;

import xj.toolkit.netty.transport.endpoint.DefaultServerEndpoint;
import xj.toolkit.util.MutablePropertyable;

/**
 * @author <a href="mailto:cxj2000@gmail.com">xiaojian.cao</a>
 *
 */
public class BusiServerEndpoint<I> extends DefaultServerEndpoint<I> {

	@Override
	public void send(I msg) {
		throw new UnsupportedOperationException("send(Object req, I response) instead.");
	}
	
	@Override
	public void send(Object req, I response) {
		Preconditions.checkArgument(req != null);
		Preconditions.checkArgument(response != null);
		
		if (req instanceof MutablePropertyable && response instanceof MutablePropertyable) {
			MutablePropertyable mReq = (MutablePropertyable) req;
			MutablePropertyable mResp = (MutablePropertyable) response;
			
			mResp.setProperties(mReq.getProperties());
		}
		
		this.channel.writeAndFlush(response);
	}

	
}
